//
//  SEGGetCommunityBizConfigManager.m
//  Commom
//
//  Created by 山刘 on 2019/4/16.
//  Copyright © 2019年 山刘. All rights reserved.
//

#import "SEGGetCommunityBizConfigManager.h"
static id _getCommunityBizConfigManager;
static dispatch_once_t onceToken;
@implementation SEGGetCommunityBizConfigManager
+(instancetype)sharedManager{
    dispatch_once(&onceToken, ^{
        _getCommunityBizConfigManager = [[self alloc] init];
    });
    return _getCommunityBizConfigManager;
}

+(void)destroyResource{
    onceToken = 0;
    _getCommunityBizConfigManager = nil;
}

-(void)getCommunityBizConfigWithCommunityId:(NSString*)communityId
{
    NSDictionary* params = @{@"communityId" : communityId};
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/",kUhomecp_esgateway,@"/rest-api/v1/ocm/getCommunityBizConfig",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params completed:^(BOOL isSuccessed, id result, NSString *codeType, NSError *error) {
        if (result == nil) {
            [[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:@"SELFAPPROVE"];
            return;
        }
        if (![[result valueForKey:@"data"] isKindOfClass:[NSDictionary class]]) {
            return;
        }
        NSDictionary *dic=result[@"data"];
        NSString *selfApprove = [[dic allKeys] containsObject:@"selfApprove"] ? [dic valueForKey:@"selfApprove"] : @"0";
        //selfApproves,是否资助认证权限 1为允许，0或其他为不允许
        [[NSUserDefaults standardUserDefaults] setObject:selfApprove forKey:@"SELFAPPROVE"];
    }];
}
@end
